package day_10;

public class ques1 {
    public static void main(String[] args) {
        int[][]arr={{1,0,1},{1,-1,-1},{1,-1,0}};
        boolean l=checkWon(arr);
        System.out.println(l);

    }



    public static boolean checkWon(int[][] board) {
        int width=board.length;
        int height=board[0].length;
        for(int i=0;i<height;i++){
            for(int j=0;j<width;j++){
                if(indexIsTrue(i,j,width,height)){

                    if(isWon(i,j,board)){
                        return true;
                    }
                }
            }

        }
        return false;
    }

    public static boolean indexIsTrue(int i,int j,int width,int height){
        return i+2<height&&j+2<width;
    }

    public static boolean isWon(int i,int j,int[][]board){
        //竖
        if(board[i][j]==board[i+1][j]&&board[i+1][j]==board[i+2][j]){
            return true;
        }
        //横
        if(board[i][j]==board[i][j+1]&&board[i][j+1]==board[i][j+2]){
            return true;
        }
        //斜线
        if(board[i][j]==board[i+1][j+1]&&board[i+1][j+1]==board[i+2][j+2]){
            return true;
        }
        return false;
    }
}
